#include "player.h"

Player::Player()
{
	turn = 0;	//use: to calculate positon of card
	cards_score = 0; //related to CalculateCardValue,
			 //is sum of current cards values
	cash = CASH;
	//this array will remember all cards nb in game
	//to help with issue 6
	for (int i=0; i < 10; i++)
		remember_cards[i] = 0;
}

void Player::UpdateCardScore(int cardScore)
{
	cards_score += cardScore;
	return;
}

void Player::UpdateCash(int c, bool takeOrAdd)
{
	if (takeOrAdd == true)
		cash -= c;
	else
		cash += c;
	return;
}

void Player::UpdateTurn()
{
	turn += 1;
	return;
}

void Player::UpdateTurnMinus()
{
	turn -= 1;
	return;
}
/*
	Calculate coordinates for card.
	For example: if is first card then coordinates are dafault.
	If is second card e.g. for computer then coordinates are x+40
	y coordinates stay same
*/
int Player::GetCardCoordinates(int x)
{
	int v = turn*40;
	x = v + HUMAN_X;
	return x;
}

/*
	Check if player is still in game
*/
bool Player::CheckGame()
{
	if (cards_score > 21)
		return false;
	else
		return true;
}

int Player::GetCardsScore()
{
	return cards_score;
}

int Player::GetCash()
{
	return cash;
}

//check if player doesn't have enough money to continue play
bool Player::isMinus()
{
	if (cash <= 0)
		return true;
	else
		return false;
}

void Player::RememberCard(int cardNB)
{
	remember_cards[turn] = cardNB;
	return;
}

int Player::GetRememberedCard(int position)
{
	return remember_cards[position];
}

void Player::ResetAll()
{
	turn = 0;
	cards_score = 0;
}

void Player::ResetCash()
{
	cash = CASH;
}